//
//  OrderSectionHeader.m
//  PPDL
//
//  Created by 王洋 on 2019/8/12.
//  Copyright © 2019 王洋. All rights reserved.
//

#import "OrderSectionHeader.h"

@interface OrderSectionHeader()

//@property (nonatomic, strong) UIButton *selectBtn;
@property (nonatomic, strong) UIImageView *supplyIcon;
@property (nonatomic, strong) UIImageView *arrowIcon;
@property (nonatomic, strong) UILabel *supplyName;
@property (nonatomic, strong) UILabel *orderStatusLab;

@property (nonatomic, strong) UIView *distanceView;


@end


@implementation OrderSectionHeader

- (instancetype)initWithReuseIdentifier:(nullable NSString *)reuseIdentifier{
    
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self layout];
    }
    return self;
}

- (void)fillHeaderWithModel:(OrderListModel *)model {
    
    self.supplyName.text = [NSString stringWithFormat:@"%@",model.supplyName.length?model.supplyName:@"未获取到供应商名称"];
    self.orderStatusLab.text = [NSString stringWithFormat:@"%@",model.orderStatus];
}

- (void)layout {
    
//    [self addSubview:self.selectBtn];
    [self addSubview:self.distanceView];
    [self addSubview:self.supplyIcon];
    [self addSubview:self.supplyName];
    [self addSubview:self.arrowIcon];
    [self addSubview:self.orderStatusLab];
    
//    [self.selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(10);
//        make.centerY.mas_equalTo(0);
//    }];
    
    [self.distanceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
        make.height.mas_equalTo(5);
    }];
    
    [self.supplyIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(2.5);
//        make.width.height.mas_equalTo(20);
    }];
    
    [self.supplyName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.supplyIcon.mas_right).offset(10);
        make.centerY.mas_equalTo(self.supplyIcon);
    }];
    
    [self.arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.supplyName.mas_right).offset(10);
        make.centerY.mas_equalTo(self.supplyIcon);
    }];
    
    [self.orderStatusLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(self.supplyIcon);
    }];
}

//- (void)selectOrder {
//
//    if (self.selectOrderBlock) {
//        self.selectOrderBlock(YES);
//    }
//}

//- (UIButton *)selectBtn {
//    if (!_selectBtn) {
//        _selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//        [_selectBtn setImage:[UIImage imageNamed:@"empty_bg"] forState:UIControlStateNormal];
//
//        [_selectBtn addTarget:self action:@selector(selectOrder) forControlEvents:UIControlEventTouchUpInside];
//    }
//    return _selectBtn;
//}

- (UIImageView *)supplyIcon {
    if (!_supplyIcon) {
        _supplyIcon = [[UIImageView alloc] init];
        [_supplyIcon setImage:[UIImage imageNamed:@"order_pai"]];
    }
    return _supplyIcon;
}

- (UIImageView *)arrowIcon {
    if (!_arrowIcon) {
        _arrowIcon = [[UIImageView alloc] init];
        [_arrowIcon setImage:[UIImage imageNamed:@"arrow_666666"]];

    }
    return _arrowIcon;
}

- (UILabel *)supplyName {
    if (!_supplyName) {
        _supplyName = [[UILabel alloc] init];
        _supplyName.font = [UIFont systemFontOfSize:14];
        _supplyName.textColor = UIColorHex(0x333333);
        _supplyName.text = @"供应商名称";
    }
    return _supplyName;
}

- (UILabel *)orderStatusLab {
    if (!_orderStatusLab) {
        _orderStatusLab = [[UILabel alloc] init];
        _orderStatusLab.text = @"订单状态";
        _orderStatusLab.font = [UIFont systemFontOfSize:13];
        _orderStatusLab.textColor = PP_Default_Color_Red_FF3737;

    }
    return _orderStatusLab;
}

- (UIView *)distanceView {
    if (!_distanceView) {
        _distanceView = [[UIView alloc] init];
        _distanceView.backgroundColor = UIColorHex(0xf5f5f5);
    }
    return _distanceView;
}

@end
